<template>
	<view>
		<u-list>
			<u-list-item v-for="(item, index) in swiperList" :key="item.id">
				<u-cell :title="item.title">
					<u-avatar slot="icon" shape="square" size="35"
						:src="'http://127.0.0.1:8080/blogimages/'+item.imgUrl" customStyle="margin: -3px 5px -3px 0">
					</u-avatar>
				</u-cell>
			</u-list-item>

		</u-list>
		<uni-fab  horizontal="right" vertical="bottom" @fabClick="toAddSwiper"
			></uni-fab>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiperList: []
			};
		},
		onLoad() {
			var _this = this
			uni.$on('addSwiper',function(data){
				_this.getAllSwiper()
			})
			this.getAllSwiper()
		},
		methods: {
			toAddSwiper(){
				uni.navigateTo({
					url:'/pages/swiper/addSwiper'
				})
			},
			getAllSwiper() {
				uni.request({
					url: 'http://127.0.0.1:8080/swiper/getAllSwiper',
					method: 'POST',
					header: {
						'token': uni.getStorageSync('token')
					},
					success: (res) => {
						console.log(res.data);
						this.swiperList = res.data.data

					},
					fail: (err) => {
						console.log('err', err)
					}
				});
			}
		},

	}
</script>

<style lang="scss">

</style>
